package com.mck.controller;

import com.mck.entity.Result;
import com.mck.entity.Score;
import com.mck.entity.ScoreRadio;
import com.mck.service.ScoreRadioService;
import com.mck.service.ScoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0.0
 * @Author mck
 * @Date 2025/2/21 下午11:36
 * @注释
 */

@RestController
@RequestMapping("/api/public/score")
@Slf4j
public class ScoreController {

    @Autowired
    private ScoreRadioService scoreRadioService;
    @Autowired
    private ScoreService scoreService;

    // 获取成绩比例
    @GetMapping("/radio")
    public Result getScoreRatio() {
        log.info("获取成绩比例");

        List<ScoreRadio> radioList =  scoreRadioService.getScoreRatio();
        return Result.success(radioList);
    }

    // 获取成绩列表
    @GetMapping
    public Result getScoreList() {
        log.info("获取成绩列表");

        List<Score> scoreList = scoreService.getScoreList();
        return Result.success(scoreList);
    }

    // 获取指定成绩列表
    @PostMapping("/specific")
    public Result getScoreListBySpecific(@RequestBody Score score) {
        log.info("获取指定成绩列表");
        // System.out.println(score);

        List<Score> scoreList = scoreService.getScoreListBySpecific(score);
        return Result.success(scoreList);
    }

    // 添加成绩列表
    @PostMapping
    public Result addScoreList(@RequestBody List<Score> scoreList) {
        log.info("添加成绩");

        scoreService.addScoreList(scoreList);
        return Result.success();
    }

    // 修改成绩
}
